/*
 * signalslice.cpp
 *
 *  Created on: Aug 3, 2009
 *      Author: zaca
 */

#include "biosignal.h"
#include "signalslice.h"

#include <iostream>
namespace biosignal {

SignalSlice::SignalSlice(const BioSignal* biosignal, TimePeriod time_period, shared_ptr<const montage::Montage> montage) {
    m_time_period = time_period;
    m_biosignal = biosignal;
    if (montage) {
        m_montage = montage;
    } else {
        m_montage = m_biosignal->ref_montage();
    }
}

DataFrameIterator SignalSlice::begin() const {
    DataFrameIterator begin(this, m_time_period.begin());
    return begin;
}

DataFrameIterator SignalSlice::end() const {
    DataFrameIterator end(this, m_time_period.end());
    return end;
}

const BioSignal* SignalSlice::biosignal() const {
    return m_biosignal;
}

TimePeriod SignalSlice::time_period() const {
    return m_time_period;
}

shared_ptr<const montage::Montage> SignalSlice::montage() const {
    return m_montage;
}

std::list<Data> SignalSlice::all_data() const {
    std::list<Data> result;
    for (int c = 0; c < 5; c++) {
        Data channel;
        int N=1000;
        channel.data = new double[N];
        channel.values = N;
        channel.label="channel ";
        channel.sample_rate=128;

        /*	for(int i=0; i<r; i++) {
         for(int j=0; j<c; j++) {
         if(i<=j) {
         result.data[i*j]=5;
         } else {
         result.data[i*j]=0;
         }
         }
         }
         */
        for (int i = 0; i < N; i++) {
            channel.data[i] = i;
        }

        result.push_back(channel);
    }
    return result;
}

}
